<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html>
<html>
    <head>
        <title></title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

    </head>
    <body>
        <?php
        require 'connect.inc';
        require 'session.inc';
        $res = "";
        $state = 0;
        $result;
        $res = "";
        if ($_SESSION["isLogin"] == 0)
            header("Location: login.php");
        else {
            $iduser = $_SESSION['iduser'];
            $res .="<table width='100%' border='1' cellspacing='0'>
                    <tbody>
                        <tr></tr>
                        <tr>
                            <td>
                                <img src='logo.jpg'>
                            </td>
                            <td>
                                <h1>Photo Album Website</h1>
                            </td>
                        </tr>
                        <tr>
                            <td width='20%' valign='top'>
                                <a href='index.php'>Home</a>
                                <br>
                                <a href='my_albums.php'>My Albums</a>
                                <br>
                                <a href='users.php'>Other persons</a>
                            </td><td>
                            <table>
                                <tbody>
                                    <tr>
                                        <td rowspan='5'>";
            $strSQL = "SELECT * FROM USERS WHERE user_id = $iduser";
            $result = mysql_query($strSQL);
            $username = $_SESSION["username"];
            $fullname = $_SESSION["fullName"];
            $email = $_SESSION["email"];
            $phone = "";
            $join_date = "";
            if ($result)
                while ($row = mysql_fetch_array($result)) {
                    if ($row["phone"] == "")
                        $phone = "No Phone";
                    else
                        $phone = $row["phone"];
                    $join_date = $row["join_date"];
                    $avatar = $row['avatar'];
                    $path = "./upload/$iduser/avatar/$avatar";
                    $res .= "<img src='$path' hieght ='200'>";
                    $res .= "</td>
                            <td>* Full Name: $fullname</td>
                        </tr>
                        <tr>
                            <td>* User Name: $username</td>
                        </tr>
                        <tr>
                            <td>* Email: $email</td>
                        </tr>
                        <tr>
                            <td>* Join Date:$phone</td>
                        </tr>
                        <tr>
                            <td>* Phone:$join_date</td>
                        </tr>";
                    break;
                }
                $res .=" </tbody>
                       </table>
                         <br/><hr>
                        My albums:
                     <br>
                        <center>
                        
                    </center>";   
            $strSQL = "SELECT a.`album_id`,a.`album_name`, a.`avatar`
                    FROM `album` a
                    WHERE a.`owner` = $iduser";
            //echo $strSQL;
            $result = mysql_query($strSQL);
            if ($result) {
                if (mysql_num_rows($result) < 1)
                    $res .= "No Album!";
                else
                    while ($row = mysql_fetch_array($result)) {
                        $idAlbum = $row["album_id"];
                        $avatar = $row["avatar"];
                        $name = $row["album_name"];
                        $res .= "<table style='float:left;'>
                        <tbody>
                            <tr>
                                <td>
                                    <a href='edit_album.php?album_id=$idAlbum'>Edit</a>
                                        |
                                    <a href='view_album.php?album_id=$idAlbum'>View</a>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <img height='100' src='./upload/$iduser/$idAlbum/avatar/$avatar'>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <a href='view_album.php?user_id=$iduser&album_id=$idAlbum'>$name</a>
                                </td>
                            </tr>
                        </tbody>
                    </table>";
                    }
            }
            // User logged in

            $res .= " <td width='20%' valign='top'>
                Wellcom <a href='#'>" . $_SESSION["username"] . "</a>!
                |
                <a href='logout.php'>Logout</a></td>
            </tr>
        </tbody>
        </table>";

            echo $res;
        }
        ?>
    </body>


</html>
